const request = function({url,baseUrl, method = "get", data, headerConfig = {}}) {
	console.log(console.log(process.env.NODE_ENV)) //自己运行的时候，直接就是development，发行的时候、这个变量就是production
	// const loginBaseUrl = 'https://env-00jxham84tk1.dev-hz.cloudbasefunction.cn/'
	const dataBaseUrl = baseUrl || 'http://localhost:8002'
	console.log(baseUrl, dataBaseUrl)
	return new Promise((resolve, reject) => {
		const token = uni.getStorageSync('token')
		let requestConfig = {
			url: dataBaseUrl + url,
			method,
			data,
			header: token ? {Authorization: token,...headerConfig} : { ...headerConfig },
			success(res) {
				if(res.statusCode===200) {
					resolve(res.data) //代表着promise对象.then方法执行
				} else if(res.statusCode===500) {
					reject('服务器端错误')
				}
			},
			fail(err) {
				reject('调用接口失败')
			}
		}
		uni.request(requestConfig)
	})
}
export default request